#  测试代码，用于测试服务端
import requests,pprint
import time
import datetime
import json
#
# payload1 = {
#         'phonenumber': '17585910623'
# }
#
# response1 = requests.post('http://10.128.223.83:8001/reception/signin',
#                           data=payload1)
# # print(response1)
# pprint.pprint(response1.json())
#
# # payload2 = {
# #         'rid': '302'
# # }
# #
# # response2 = requests.post('http://127.0.0.1/reception/logout',
# #                           data=payload2)
# # # print(response1)
# # pprint.pprint(response2.json())
#
# # payload3 = {
# #         'time': datetime.datetime.now()
# # }
# #
# # response3 = requests.post('http://127.0.0.1/admin/createreport',
# #                           data=payload3)
# # # print(response3)
# # pprint.pprint(response3.json())
#
# # payload4 = {
# #         'rid': '302',
# #         'discount': 0.7
# # }
# #
# # response4 = requests.post('http://127.0.0.1/admin/discount',
# #                           data=payload4)
# # # print(response3)
# # pprint.pprint(response4.json())
#
# # payload5 = {
# #         'state': 0
# # }
# #
# # response5 = requests.post('http://127.0.0.1/admin/centerturnonoff',
# #                           data=payload5)
# # # print(response3)
# # pprint.pprint(response5.json())
#
# # 管理员登录测试
# payload5 = {
#         'username': '302',
#         'password':'11111111'
# }
#
# response5 = requests.post('http://192.168.43.104:8001/admin/login',
#                           data=payload5)
# # print(response3)
# pprint.pprint(response5.json())
# #
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'hotelsys.settings'
from django.core import signing
value1 = signing.dumps({'username':'rootroot'})
src1 = signing.loads(value1)
print(value1)
print(src1)
value2 = signing.dumps({'checkinDate':str(datetime.datetime.now())})
src2 = signing.loads(value2)
print(value2)
print(src2)


# url = 'http://10.128.223.83:8001/reception/logout'
# body = {'rid': '302'}
# headers = {'content-type': "application/json", 'Authorization': '302|eyJyaWQiOiIzMDIifQ:1lVQJC:eA-VVVpxak0hXs1Z1TH8yDqEha6GGBe_GdULvLF6Tmw,'
#                                                                 '2021-04-11 10:58:46.708939|eyJjaGVja2luRGF0ZSI6IjIwMjEtMDQtMTEgMTA6NTg6NDYuNzA4OTM5In0:1lVQJC:g3Twc3zZsu0rYylwlzvH4-ryFjr-qKnQIZGuZWDP8Rc'}
# response = requests.post(url, data = body, headers = headers)
# pprint.pprint(response.json())

# url = 'http://127.0.0.1:8001/admin/centerturnonoff'
# body = {'state': 0}
# name = '张三'.encode("utf-8").decode("latin1")
# headers = {'content-type': "application/x-www-form-urlencoded", 'Authorization': f'{name}|eyJ1c2VybmFtZSI6Ilx1NWYyMFx1NGUwOSJ9:1lVQg2:3pp7O7EX7bOuPfaGYcuXolc88dEMJ5a_m1jtgOpQXCo'}
# response = requests.post(url, data = body, headers = headers)
# pprint.pprint(response.json())


#测试waterbill
# url = 'http://127.0.0.1:8001/admin/createwaterbills'
# body = {'date': '1618132307000'}
# name = 'rootroot'.encode("utf-8").decode("latin1")
# headers = {'content-type': "application/json", 'Authorization': f'{name}|eyJ1c2VybmFtZSI6InJvb3Ryb290In0:1lVVEg:yxaLohILMRpe8o0ujODLlpWCiNUk32tfrEFxrB8jbkI'}
# response = requests.post(url, data = body, headers = headers)
# pprint.pprint(response.json())

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'hotelsys.settings'
from django.core import signing
value1 = signing.dumps({'rid':'302'})
src1 = signing.loads(value1)
print(value1)
print(src1)
value2 = signing.dumps({'checkinDate':str(datetime.datetime.now())})
src2 = signing.loads(value2)
print(value2)
print(src2)